# Maintainer: Anatol Pomozov <anatol dot pomozov at gmail>
# Contributor: Mariusz Libera <mariusz.libera@gmail.com>
# Contributor: John Williams <jwilliams4200 liamg reverse&remove moc>

pkgname=fio
pkgver=3.34
pkgrel=1
pkgdesc='Scriptable I/O tool for storage benchmarks and drive testing'
arch=(loong64 x86_64)
url='https://github.com/axboe/fio'
license=(GPL2)
# TODO: enable rdma, need to move the libraries from AUR
depends=(bash libaio python numactl glusterfs gperftools)
makedepends=(gtk2 curl)
optdepends=(
  'gtk2: for gfio - fio GUI frontend' 
  'curl: for gfio - fio GUI frontend'
  'gnuplot: generating plots using fio_generate_plots'
)
source=(https://github.com/axboe/fio/archive/fio-$pkgver.zip)
sha256sums=('30543dcae7442f7945302b347306a49a2c8948da4661bacacce35f048f54f5ef')

prepare() {
  cd fio-fio-$pkgver
  sed -e 's|#!/usr/bin/python2.7$|#!/usr/bin/python|' -i tools/{fio_jsonplus_clat2csv,fiologparser.py,hist/fiologparser_hist.py,hist/half-bins.py,plot/fio2gnuplot}
}

build() {
  cd fio-fio-$pkgver
  ./configure --disable-native --enable-gfio --extra-cflags="$CFLAGS"
  make
}

package() {
  cd fio-fio-$pkgver
  make DESTDIR="$pkgdir" prefix=/usr mandir=/usr/share/man install

  # documentation
  install -dm755 "$pkgdir/usr/share/doc/$pkgname"
  install -m644 HOWTO.rst README.rst REPORTING-BUGS SERVER-TODO "$pkgdir/usr/share/doc/$pkgname"
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
  install -Dm644 MORAL-LICENSE "$pkgdir/usr/share/licenses/$pkgname/MORAL-LICENSE"

  # examples
  install -dm755 "$pkgdir/usr/share/doc/$pkgname/examples"
  install -m644 examples/* "$pkgdir/usr/share/doc/$pkgname/examples"
}
